package cn.pinming.chyn.tools.utils;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public class CollectionUtil {

	private final static String DEFAULT_DELIMITER = "," ;
	
	public static String join(List<String> list) {
		return join(list , DEFAULT_DELIMITER) ;
	}
	
	public static String join(String [] arr) {
		return join(arr , DEFAULT_DELIMITER) ;
	}
	
	public static String join(String [] arr , String delimiter) {
		List<String> list = Arrays.asList(arr) ;
		return join(list, delimiter) ;
	}
	
	public static String join(List<String> list , String delimiter) {
		if(list == null || list.size() == 0) {
			return "" ; 
		}
		return list.stream().collect(Collectors.joining(delimiter)) ;
	}
	
}
